<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">


<ui:composition template="/templates/internal.xhtml">
	<ui:define name="center">
		<script type="text/javascript">
			$( document ).ready(function() {
				wlayout.layout.hide('south');
				wlayout.layout.open('west');
			});			
		</script>	
		<p:outputPanel id="content" layout="block" style="height:100%;width:100%">
			<ui:include src="/library/libraryForm.xhtml"/>
		</p:outputPanel>
	</ui:define>
	<ui:define name="menu">
		<h:form id="listLibraryForm" style="overflow:hidden">

				<p:contextMenu for="docTree" nodeType="root"  >
					<p:menuitem value="#{msgs.Create}..."	action="#{libraryBean.toAddLibrary}" update=":content"  icon="ui-icon-document">
						<f:setPropertyActionListener target="#{libraryBean.libraryViewType}" value="#{1}"/>
					</p:menuitem> 
				</p:contextMenu>

				<p:contextMenu for="docTree" nodeType="library"  >
					<p:menuitem value="#{msgs.Copy}" 	action="#{libraryBean.toCopy}"  icon="ui-icon-copy"/>
					<p:menuitem value="#{msgs.Edit}"	action="#{libraryBean.toEditLibrary}" update=":content,listLibraryForm"  icon="ui-icon-pencil">
						<f:setPropertyActionListener target="#{libraryBean.libraryViewType}" value="#{1}"/>
					</p:menuitem> 
					<p:menuitem value="#{msgs.Paste}"	icon="ui-icon-document-b"/> 
					<p:menuitem value="#{msgs.Delete}"	action="#{libraryBean.toDeleteLibrary}"	icon="ui-icon-trash"/>
				</p:contextMenu>
						
				<p:contextMenu for="docTree" nodeType="modality"   >
					<p:menuitem value="#{msgs.Copy}" 	action="#{libraryBean.toCopy}"  icon="ui-icon-copy"/>
					<p:menuitem value="#{msgs.Paste}"	icon="ui-icon-document-b"/> 
					<p:menuitem value="#{msgs.Delete}"	icon="ui-icon-trash"/>
				</p:contextMenu>
				
				<p:contextMenu for="docTree" nodeType="training"  >
					<p:menuitem value="#{msgs.Copy}" 	action="#{libraryBean.toCopy}"  icon="ui-icon-copy"/>
					<p:menuitem value="#{msgs.Paste}"	icon="ui-icon-document-b"/> 
					<p:menuitem value="#{msgs.Delete}"	icon="ui-icon-trash"/>
				</p:contextMenu>
				
				<p:contextMenu for="docTree" nodeType="trainingSystem"  >
					<p:menuitem value="#{msgs.Copy}" 	action="#{libraryBean.toCopy}"  icon="ui-icon-copy"/>
					<p:menuitem value="#{msgs.Paste}"	icon="ui-icon-document-b"/> 
					<p:menuitem value="#{msgs.Delete}"	icon="ui-icon-trash"/>
				</p:contextMenu>

				<p:contextMenu for="docTree" nodeType="exerciseGroup"  >
					<p:menuitem value="#{msgs.Copy}" 	action="#{libraryBean.toCopy}"  icon="ui-icon-copy"/>
					<p:menuitem value="#{msgs.Paste}"	icon="ui-icon-document-b"/> 
					<p:menuitem value="#{msgs.Delete}"	icon="ui-icon-trash"/>
				</p:contextMenu>

				<p:contextMenu for="docTree" nodeType="equipment"  >
					<p:menuitem value="#{msgs.Copy}" 	action="#{libraryBean.toCopy}"  icon="ui-icon-copy"/>
					<p:menuitem value="#{msgs.Paste}"	icon="ui-icon-document-b"/> 
					<p:menuitem value="#{msgs.Delete}"	icon="ui-icon-trash"/>
				</p:contextMenu>
				
				<p:tree id="docTree" value="#{libraryBean.root}" var="node" dynamic="true"
					selectionMode="multiple" selection="#{libraryBean.selNodes}" style="width:97%" >
					
					<p:ajax event="select"  listener="#{libraryBean.onNodeSelect}" update=":content" /> 
					
					<p:treeNode expandedIcon="ui-icon-folder-open"  
				                  collapsedIcon="ui-icon-folder-collapsed">  
						<h:outputText value="#{node}" />
					</p:treeNode>  			


					<p:treeNode type="root" expandedIcon="ui-icon-folder-open"  
				                  collapsedIcon="ui-icon-folder-collapsed">
					    <h:outputText value="#{node}" />
					</p:treeNode>		        


					<p:treeNode type="library" expandedIcon="ui-icon-folder-open"  
				                  collapsedIcon="ui-icon-folder-collapsed">
					    <h:outputText value="#{node.name}" />
					</p:treeNode>		        


					<p:treeNode type="shared" expandedIcon="ui-icon-folder-open"  
				                  collapsedIcon="ui-icon-folder-collapsed">
					    <h:outputText value="#{node}" />
					</p:treeNode>		        

					<p:treeNode type="public" expandedIcon="ui-icon-folder-open"  
				                  collapsedIcon="ui-icon-folder-collapsed">
					    <h:outputText value="#{node}" />
					</p:treeNode>		        

					<p:treeNode type="personal" expandedIcon="ui-icon-folder-open"  
				                  collapsedIcon="ui-icon-folder-collapsed">
					    <h:outputText value="#{node}" />
					</p:treeNode>		        


					<p:treeNode type="modalitys" icon="ui-icon-document" >
					    <h:outputText value="#{node}" />
					</p:treeNode>		        
					<p:treeNode type="modality" icon="ui-icon-document" >
					    <h:outputText value="#{node.name}" />
					</p:treeNode>		        
					
					<p:treeNode type="trainings" icon="ui-icon-document">
					    <h:outputText value="#{node}" />
					</p:treeNode>	
					<p:treeNode type="training" icon="ui-icon-document">
					    <h:outputText value="#{node.name}" />
					</p:treeNode>	

					<p:treeNode type="trainingSystems" icon="ui-icon-document">
					    <h:outputText value="#{node}" />
					</p:treeNode>								
					<p:treeNode type="trainingSystem" icon="ui-icon-document">
					    <h:outputText value="#{node.name}" />
					</p:treeNode>	

					<p:treeNode type="equipments" icon="ui-icon-document">
					    <h:outputText value="#{node}" />
					</p:treeNode>								
					<p:treeNode type="equipment" icon="ui-icon-document">
					    <h:outputText value="#{node.name}" />
					</p:treeNode>	
					
					<p:treeNode type="exerciseGroups" icon="ui-icon-document">
					    <h:outputText value="#{node}" />
					</p:treeNode>	
					<p:treeNode type="exerciseGroup" icon="ui-icon-document">
					    <h:outputText value="#{node.name}" />
					</p:treeNode>	

					
				</p:tree>  		
		</h:form>
	
	</ui:define>

	<ui:define name="dialogs">
		<ui:include src="/library/libraryDialogs.xhtml" />
	</ui:define>
</ui:composition>
	
</html>